
local excel = load_excel('捕鱼设定.xlsx','捕鱼几率')



ac.game:event '炮台-捕捉到鱼'(function(_,shop,unit)
    local player = shop.owner
    local hero = player.hero
    local name = unit.name
    local data = excel[name]
    local odds = data and data['捕获几率'] or 0
    local position = unit:get_point()
    if odds and math.random(100)<=odds then
        unit:kill()
        unit:remove()

        if name=='普通漂流箱' or name=='高级漂流箱' or name=='珍藏宝箱' then
            local num = math.random(data.data1,data.data2)
            player:add('木材',num)
            player:send_msg(('捕鱼获得|cff00ff00%0.f|r木材'):format(num))
            ac.ui_tag {
                string = ('|cff00ff00+%0.f|r'):format(num),
                speed = 200,
                life = 1,
                fade = 0.5,
                player = player,
                position = position,
            }
        end
        
        if name=='一条小鱼' or name=='大鱼' or name=='超级大鱼' or name=='深海巨鲸' or name=='泰坦鱼' then
            local num = math.random(data.data1,data.data2)
            player:add('金币',num)
            player:send_msg(('捕鱼获得|cffffff00%0.f|r金币'):format(num))
            ac.ui_tag {
                string = ('|cffffff00+%0.f|r'):format(num),
                speed = 200,
                life = 1,
                fade = 0.5,
                position = position,
                player = player,
                icon = [[图标\金币.blp]],
            }
        end
        if name=='天赋宝箱' then
            local card = unit.card
            local data = {}
            if card then
                data.title = data.name
                data.art = card.art
            end
            local item = hero:add_item('天赋宝箱',data)
            item.card = card
        end
    else
        ac.ui_tag {
            string = '|cffff0000Miss!|r',
            speed = 200,
            life = 1,
            fade = 0.5,
            player = player,
            position = unit:get_point(),
        }
    end
end)



